
import 'package:flutter/material.dart';
import 'package:fyi/pages/history_page.dart';
import 'package:fyi/pages/login_page.dart';
import 'package:fyi/router/route_app.dart';

class NavigatorUtil {

  ///跳转到指定页面
  static push(BuildContext context,Widget page){
    Navigator.push(context, MaterialPageRoute(builder: (context) => wrapApp2(page)));
  }

  static pop(BuildContext context){
    Navigator.pop(context);
  }

  ///主页
  static goHome(BuildContext context) {
    Navigator.pushReplacementNamed(context, HistoryPage.sName);
  }

  ///登录页
  static goLogin(BuildContext context) {
    Navigator.pushReplacementNamed(context, LoginPage.sName);
  }

  ///弹出 dialog
  static Future<T> showMDDialog<T>({
    @required BuildContext context,
    bool barrierDismissible = true,
    WidgetBuilder builder,
  }) {
    return showDialog<T>(
        context: context,
        barrierDismissible: barrierDismissible,
        builder: (context) {
          return MediaQuery(

            ///不受系统字体缩放影响
              data: MediaQueryData.fromWindow(WidgetsBinding.instance.window)
                  .copyWith(textScaleFactor: 1),
              child: new SafeArea(child: builder(context)));
        });
  }
}